import { IsNotEmpty, IsNumber, IsString, IsPhoneNumber, IsByteLength, Length, MinLength, MaxLength, isNotEmpty, IsEmail, IsIP, IsEmpty } from "class-validator";
import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";

export class CreateUserDto {
    @IsNotEmpty()
    @IsString()
    @Length(4, 12, { message: "字符长度在4-12个之间" })
    username: string;

    @ApiProperty({ example: '12345678', description: '密码' })
    @IsNotEmpty({ message: '密码不能为空' })
    @MinLength(6, {
        message: '密码长度不能小于6位',
    })
    @MaxLength(20, {
        message: '密码长度不能超过20位',
    })
    password: string;

    @IsNotEmpty()
    @IsPhoneNumber('CN')
    phone: string

    @IsNotEmpty({ message: "郵箱不能爲空!" })
    @IsEmail()
    email: string

    @Type(() => Number)
    @IsNumber()
    male: number

    @Type(() => Number)
    @IsNumber()
    role: number

    ip?: string
    registerTime?: string
}